import { useStorage } from "@vueuse/core";
import { defineStore } from "pinia";
import defaultSettings from "@/setting";
import { computed } from "vue";

import zhCn from "ant-design-vue/es/locale/zh_CN";
import en from "ant-design-vue/es/locale/en_US";

/**
 * 顶层状态
 */
export const useAppStore = defineStore("app", () => {
  const language = useStorage("language", defaultSettings.language);
  const size = useStorage("size", defaultSettings.size);
  const locale = computed(() => (language.value === "en" ? en : zhCn));

  return {
    language,
    size,
    locale,
  };
});
